package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collection;

class zani extends CollectionBase {
   public CellArea a(int var1) {
      return (CellArea)this.a.get(var1);
   }

   void a(CellArea var1) {
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)var1);
   }

   void a(int var1, CellArea var2) {
      this.a.set(var1, var2);
   }

   void a(int var1, int var2) {
      if (this.a.size() != 0) {
         for(int var3 = 0; var3 < this.a.size(); ++var3) {
            CellArea var4 = (CellArea)this.a.get(var3);
            boolean var5 = false;
            boolean[] var6 = new boolean[]{var5};
            var4 = zayd.a(var4, var1, var2, var6);
            var5 = var6[0];
            if (!var5 && !var4.b()) {
               this.a.set(var3, var4);
            } else {
               this.a.remove(var3);
               --var3;
            }
         }
      }

   }

   void b(int var1, int var2) {
      if (this.a.size() != 0) {
         for(int var3 = 0; var3 < this.a.size(); ++var3) {
            CellArea var4 = (CellArea)this.a.get(var3);
            boolean var5 = false;
            boolean[] var6 = new boolean[]{var5};
            var4 = zayd.b(var4, var1, var2, var6);
            var5 = var6[0];
            if (!var5 && !var4.b()) {
               this.a.set(var3, var4);
            } else {
               this.a.remove(var3);
               --var3;
            }
         }
      }

   }

   boolean c(int var1, int var2) {
      for(int var3 = 0; var3 < this.a.size(); ++var3) {
         CellArea var4 = (CellArea)this.a.get(var3);
         if (var4.StartRow <= var1 && var4.EndRow >= var1 && var4.StartColumn <= var2 && var4.EndColumn >= var2) {
            return true;
         }
      }

      return false;
   }

   public Range a(Cells var1, int var2, int var3) {
      for(int var4 = 0; var4 < this.a.size(); ++var4) {
         CellArea var5 = (CellArea)this.a.get(var4);
         if (var5.StartRow <= var2 && var5.EndRow >= var2 && var5.StartColumn <= var3 && var5.EndColumn >= var3) {
            return var1.createRange(var5.StartRow, var5.StartColumn, var5.EndRow - var5.StartRow + 1, var5.EndColumn - var5.StartColumn + 1);
         }
      }

      return null;
   }

   public void a(int var1, int var2, int var3, int var4) {
      if (var3 != 0 && var4 != 0) {
         zakq.a(var1, var2, var1 + var3 - 1, var2 + var4 - 1);
         int var5;
         CellArea var6;
         if (var3 == 1 && var4 == 1) {
            for(var5 = 0; var5 < this.a.size(); ++var5) {
               var6 = (CellArea)this.a.get(var5);
               if (var6.StartRow <= var1 && var6.EndRow >= var1 && var6.StartColumn <= var2 && var6.EndColumn >= var2) {
                  this.a.remove(var5);
                  return;
               }
            }

         } else {
            for(var5 = 0; var5 < this.a.size(); ++var5) {
               var6 = (CellArea)this.a.get(var5);
               if (var6.StartRow == var1 && var6.EndRow == var1 + var3 - 1 && var6.StartColumn == var2 && var6.EndColumn == var2 + var4 - 1) {
                  this.a.remove(var5);
                  return;
               }
            }

         }
      } else {
         throw new IllegalArgumentException("Row number or column number cannot be zero");
      }
   }

   public void a(Cells var1, int var2, int var3, int var4, int var5) {
      if (var4 != 0 && var5 != 0) {
         zakq.a(var2, var3, var2 + var4 - 1, var3 + var5 - 1);
         if (var5 != 1 || var4 != 1) {
            CellArea var6 = new CellArea();
            var6.StartRow = var2;
            var6.StartColumn = var3;
            var6.EndRow = var2 + var4 - 1;
            var6.EndColumn = var3 + var5 - 1;

            for(int var7 = 0; var7 < this.a.size(); ++var7) {
               CellArea var8 = (CellArea)this.a.get(var7);
               Object var9 = zayd.e(var6, var8);
               if (var9 != null) {
                  CellArea var10 = (CellArea)var9;
                  if (var10.StartRow != var8.StartRow || var10.StartColumn != var8.StartColumn || var10.EndRow != var8.EndRow || var10.EndColumn != var8.EndColumn) {
                     StringBuilder var11 = new StringBuilder();
                     var11.append("Cells in range ");
                     var11.append(CellsHelper.cellIndexToName(var6.StartRow, var6.StartColumn));
                     var11.append(':');
                     var11.append(CellsHelper.cellIndexToName(var6.EndRow, var6.EndColumn));
                     var11.append(" cannot be merged because cells in range ");
                     var11.append(CellsHelper.cellIndexToName(var8.StartRow, var8.StartColumn));
                     var11.append(':');
                     var11.append(CellsHelper.cellIndexToName(var8.EndRow, var8.EndColumn));
                     var11.append(" have already been merged.");
                     throw new CellsException(10, com.aspose.cells.b.a.zr.a(var11));
                  }

                  this.a.remove(var7--);
               }
            }

            boolean var13 = false;
            Cell var14 = var1.a(var2, var3, false);

            for(int var15 = var2; var15 < var2 + var4; ++var15) {
               Row var16 = var1.getRows().a(var15, true, false, false);
               if (var16 != null) {
                  for(int var17 = var3; var17 < var3 + var5; ++var17) {
                     Cell var12 = var16.getCellOrNull(var17);
                     if (var12 != null && var12.c.c != 0) {
                        if (!var13) {
                           if (var12 != var14) {
                              switch(var12.c.c) {
                              case 1:
                              case 6:
                                 var14.a(var12.c.c, var12.c.d, true);
                                 break;
                              case 4:
                                 var14.a((Cell)var12, (CopyOptions)null);
                              }

                              var14.b(var12.r());
                           }

                           var13 = true;
                        }

                        if (var15 != var2 || var17 != var3) {
                           var12.putValue((String)null);
                        }
                     }
                  }
               }
            }

            com.aspose.cells.b.a.a.ze.a(this.a, (Object)var6);
         }
      } else {
         throw new IllegalArgumentException("Row number or column number cannot be zero");
      }
   }

   public void a(Cells var1, int var2, int var3, int var4, int var5, boolean var6, boolean var7) {
      if (var4 != 0 && var5 != 0) {
         zakq.a(var2, var3, var2 + var4 - 1, var3 + var5 - 1);
         CellArea var8 = new CellArea();
         var8.StartRow = var2;
         var8.StartColumn = var3;
         var8.EndRow = var2 + var4 - 1;
         var8.EndColumn = var3 + var5 - 1;
         if (var6) {
            for(int var9 = 0; var9 < this.a.size(); ++var9) {
               CellArea var10 = (CellArea)this.a.get(var9);
               Object var11 = zayd.e(var8, var10);
               if (var11 != null) {
                  CellArea var12 = (CellArea)var11;
                  if (var12.StartRow == var10.StartRow && var12.StartColumn == var10.StartColumn && var12.EndRow == var10.EndRow && var12.EndColumn == var10.EndColumn) {
                     this.a.remove(var9--);
                  } else {
                     if (!var7) {
                        StringBuilder var13 = new StringBuilder();
                        var13.append("Cells in range ");
                        var13.append(CellsHelper.cellIndexToName(var8.StartRow, var8.StartColumn));
                        var13.append(':');
                        var13.append(CellsHelper.cellIndexToName(var8.EndRow, var8.EndColumn));
                        var13.append(" cannot be merged because cells in range ");
                        var13.append(CellsHelper.cellIndexToName(var10.StartRow, var10.StartColumn));
                        var13.append(':');
                        var13.append(CellsHelper.cellIndexToName(var10.EndRow, var10.EndColumn));
                        var13.append(" have already been merged.");
                        throw new CellsException(10, com.aspose.cells.b.a.zr.a(var13));
                     }

                     if (var8.StartRow > var10.StartRow) {
                        var8.StartRow = var10.StartRow;
                     }

                     if (var8.StartColumn > var10.StartColumn) {
                        var8.StartColumn = var10.StartColumn;
                     }

                     if (var8.EndColumn < var10.EndColumn) {
                        var8.EndColumn = var10.EndColumn;
                     }

                     if (var8.EndRow < var10.EndRow) {
                        var8.EndRow = var10.EndRow;
                     }

                     this.a.remove(var9--);
                  }
               }
            }
         }

         boolean var16 = false;

         for(int var15 = var2; var15 < var2 + var4; ++var15) {
            Row var17 = var1.getRows().a(var15, true, false, false);
            if (var17 != null) {
               for(int var18 = var3; var18 < var3 + var5; ++var18) {
                  Cell var19 = var17.getCellOrNull(var18);
                  if (var19 != null && var19.c.c != 0) {
                     if (!var16) {
                        if (var15 != var2 || var18 != var3) {
                           Cell var14 = var1.a(var2, var3, false);
                           switch(var19.c.c) {
                           case 1:
                           case 6:
                              var14.a(var19.c.c, var19.c.d, true);
                              break;
                           case 4:
                              var14.a((Cell)var19, (CopyOptions)null);
                           }

                           var14.b(var19.r());
                        }

                        var16 = true;
                     }

                     if (var15 != var2 || var18 != var3) {
                        var19.putValue((String)null);
                     }
                  }
               }
            }
         }

         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var8);
      } else {
         throw new IllegalArgumentException("Row number or column number cannot be zero");
      }
   }

   ArrayList a() {
      ArrayList var1 = new ArrayList();
      com.aspose.cells.b.a.a.ze.a(var1, (Collection)this.a);
      return var1;
   }

   void b() {
      for(int var1 = this.a.size() - 1; var1 >= 0; --var1) {
         CellArea var2 = (CellArea)this.a.get(var1);
         if (var2.StartRow <= 65535 && var2.StartColumn <= 255) {
            if (var2.EndRow > 65535) {
               var2.EndRow = 65535;
               if (var2.EndColumn > 255) {
                  var2.EndColumn = 255;
               }

               this.a.set(var1, var2);
            } else if (var2.EndColumn > 255) {
               var2.EndColumn = 255;
               this.a.set(var1, var2);
            }
         } else {
            this.a.remove(var1);
         }
      }

   }

   void a(CellArea var1, int var2) {
      for(int var3 = 0; var3 < this.a.size(); ++var3) {
         CellArea var4 = (CellArea)this.a.get(var3);
         if (var4.StartColumn > var1.EndColumn) {
            if (var4.StartRow >= var1.StartRow && var4.EndRow <= var1.EndRow) {
               var4.StartColumn -= var2;
               var4.EndColumn -= var2;
               this.a.set(var3, var4);
            }
         } else if (var4.StartRow >= var1.StartRow && var4.EndRow <= var1.EndRow && var4.StartColumn >= var1.StartColumn && var4.EndColumn <= var1.EndColumn) {
            this.a.remove(var3);
            --var3;
         }
      }

   }

   void b(CellArea var1, int var2) {
      for(int var3 = 0; var3 < this.a.size(); ++var3) {
         CellArea var4 = (CellArea)this.a.get(var3);
         if (var4.StartRow > var1.EndRow) {
            if (var4.StartColumn >= var1.StartColumn && var4.EndColumn <= var1.EndColumn) {
               var4.StartRow -= var2;
               var4.EndRow -= var2;
               this.a.set(var3, var4);
            }
         } else if (var4.StartRow >= var1.StartRow && var4.EndRow <= var1.EndRow && var4.StartColumn >= var1.StartColumn && var4.EndColumn <= var1.EndColumn) {
            this.a.remove(var3);
            --var3;
         }
      }

   }

   void c(CellArea var1, int var2) {
      for(int var3 = 0; var3 < this.a.size(); ++var3) {
         CellArea var4 = (CellArea)this.a.get(var3);
         if (var1.StartColumn <= var4.StartColumn && var4.StartRow >= var1.StartRow && var4.EndRow <= var1.EndRow) {
            var4.StartColumn += var2;
            var4.EndColumn += var2;
            this.a.set(var3, var4);
         }
      }

   }

   void d(CellArea var1, int var2) {
      for(int var3 = 0; var3 < this.a.size(); ++var3) {
         CellArea var4 = (CellArea)this.a.get(var3);
         if (var1.EndRow <= var4.StartRow && var4.StartColumn >= var1.StartColumn && var4.EndColumn <= var1.EndColumn) {
            var4.StartRow += var2;
            var4.EndRow += var2;
            this.a.set(var3, var4);
         }
      }

   }

   void a(zani var1, int var2, int var3, int var4) {
      for(int var5 = 0; var5 < var1.getCount(); ++var5) {
         CellArea var6 = var1.a(var5);
         if (var6.StartColumn >= var2 && var6.EndColumn <= var2 + var4 - 1) {
            CellArea var7 = new CellArea();
            var7.StartRow = var6.StartRow;
            var7.EndRow = var6.EndRow;
            var7.StartColumn = var3 + var6.StartColumn - var2;
            var7.EndColumn = var7.StartColumn + var6.EndColumn - var6.StartColumn;
            com.aspose.cells.b.a.a.ze.a(this.a, (Object)var7);
         }
      }

   }

   void a(zani var1) {
      for(int var2 = 0; var2 < var1.getCount(); ++var2) {
         CellArea var3 = var1.a(var2);
         CellArea var4 = CellArea.c(var3);
         com.aspose.cells.b.a.a.ze.a(this.a, (Object)var4);
      }

   }

   void b(zani var1, int var2, int var3, int var4) {
      int var5;
      for(var5 = this.getCount() - 1; var5 >= 0; --var5) {
         CellArea var6 = this.a(var5);
         if (var6.StartRow >= var3 && var6.EndRow < var3 + var4) {
            this.a.remove(var6);
         }
      }

      var5 = var1.getCount();

      for(int var11 = 0; var11 < var5; ++var11) {
         CellArea var7 = var1.a(var11);
         if (var7.StartRow >= var2 && var7.EndRow < var2 + var4) {
            CellArea var8 = new CellArea();
            int var9 = var7.StartRow - var2;
            int var10 = var7.EndRow - var7.StartRow;
            var8.StartRow = var3 + var9;
            var8.EndRow = var8.StartRow + var10;
            var8.StartColumn = var7.StartColumn;
            var8.EndColumn = var7.EndColumn;
            com.aspose.cells.b.a.a.ze.a(this.a, (Object)var8);
         }
      }

   }

   void a(CellArea var1, int var2, int var3, int var4, int var5) {
      for(int var6 = 0; var6 < this.getCount(); ++var6) {
         CellArea var7 = this.a(var6);
         if (var1.StartRow <= var7.StartRow && var1.EndRow >= var7.EndRow && var1.StartColumn <= var7.StartColumn && var1.EndColumn >= var7.EndColumn) {
            var7.StartRow += var4 - var1.StartRow;
            var7.EndRow += var4 - var1.StartRow;
            var7.StartColumn += var5 - var1.StartColumn;
            var7.EndColumn += var5 - var1.StartColumn;
            this.a.set(var6, var7);
         } else if (var4 <= var7.StartRow && var4 + var2 - 1 >= var7.EndRow && var5 <= var7.StartColumn && var5 + var3 - 1 >= var7.EndColumn) {
            this.a.remove(var6--);
         }
      }

   }

   // $FF: synthetic method
   public Object get(int x0) {
      return this.a(x0);
   }
}
